import {HvigorNode, HvigorPlugin} from '@ohos/hvigor';
import {ScanTask} from "./scan-task";
import fs from "fs-extra";

export function hRouterPlugin(isLog: boolean = false): HvigorPlugin {
    return {
        pluginId: 'hRouterPlugin',
        apply(node: HvigorNode) {
            let appConfig = fs.readJsonSync(node.getParentNode()!!.getNodePath()!! + "/AppScope/app.json5")
            if (isLog)
                console.info("bundleName", appConfig.app.bundleName)
            node.registerTask(new ScanTask(appConfig.app.bundleName,isLog))
        }
    }
}

